package com.wc.alorithm_luogu.P1098;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/26 13:18
 * @description https://www.luogu.com.cn/problem/P1098
 * 字符串的展开
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int p1 = Integer.parseInt(sc.next());
        int p2 = Integer.parseInt(sc.next());
        int p3 = Integer.parseInt(sc.next());

        sc.nextLine();
        String s = sc.nextLine();
        StringBuilder ans = new StringBuilder();
        char[] chs = s.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            if (chs[i] == '-') {
                ans.append(fill(chs, i, p1, p2, p3));
            } else {
                ans.append(chs[i]);
            }
        }
        System.out.println(ans);
    }

    /**
     * 填充
     *
     * @param chs   填充的数组
     * @param index "-"的位置
     * @param p1    1 字符小写 2 字符大写 3 填充为*   1 2 对于数字不生效
     * @param p2    k 表示字符重复次数
     * @param p3    1 顺序    2 逆序
     * @return
     */
    public static String fill(char[] chs, int index, int p1, int p2, int p3) {
        // 左边界
        int leftIndex = index - 1;
        // 有边界
        int rightIndex = index + 1;

        if (leftIndex < 0 || rightIndex == chs.length) {
            return "-";
        }
        // 存放答案
        StringBuilder ret = new StringBuilder();
        // “-”左边的字符
        char left = chs[leftIndex];
        // “-”右边的字符
        char right = chs[rightIndex];


        // 判断是否同为数字
        if (left >= '0' && left <= '9' && right >= '0' && right <= '9') {
            if (left + 1 == right) {
                return "";
            }
            if (left < right) {
                left++;
                right--;

                if (p1 == 3) {
                    while (left <= right) {
                        for (int i = 0; i < p2; i++) {
                            ret.append('*');
                        }
                        left++;
                    }
                }

                while (left <= right) {
                    if (p3 == 1) {
                        for (int i = 0; i < p2; i++) {
                            ret.append(left);
                        }
                        left++;
                    } else {
                        for (int i = 0; i < p2; i++) {
                            ret.append(right);
                        }
                        right--;
                    }
                }
            }
            // 判断是否同为字母
        } else if (left >= 'a' && left <= 'z' && right >= 'a' && right <= 'z') {
            if (left + 1 == right) {
                return "";
            }
            if (left < right) {
                left++;
                right--;
                if (p3 == 1) {
                    if (p1 == 1) {
                        while (left <= right) {
                            for (int i = 0; i < p2; i++) {
                                ret.append(left);
                            }
                            left++;
                        }
                    } else if (p1 == 2) {
                        left += 'A' - 'a';
                        right += 'A' - 'a';
                        while (left <= right) {
                            for (int i = 0; i < p2; i++) {
                                ret.append(left);
                            }
                            left++;
                        }
                    } else {
                        while (left <= right) {
                            for (int i = 0; i < p2; i++) {
                                ret.append('*');
                            }
                            left++;
                        }
                    }
                } else {
                    if (p1 == 1) {
                        while (left <= right) {
                            for (int i = 0; i < p2; i++) {
                                ret.append(right);
                            }
                            right--;
                        }
                    } else if (p1 == 2) {
                        left += 'A' - 'a';
                        right += 'A' - 'a';
                        while (left <= right) {
                            for (int i = 0; i < p2; i++) {
                                ret.append(right);
                            }
                            right--;
                        }
                    } else {
                        while (left <= right) {
                            for (int i = 0; i < p2; i++) {
                                ret.append('*');
                            }
                            left++;
                        }
                    }
                }
            }
        }

        if (ret.length() == 0) {
            return "-";
        }
        return ret.toString();
    }
}
